package cn.edu.fzu.delivery.domain.handler;

import cn.edu.fzu.delivery.domain.enums.NetWorkTypeEnum;
import cn.edu.fzu.delivery.domain.enums.NetWorkStatusEnum;
import cn.edu.fzu.delivery.domain.enums.NetWorkTypeEnum;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author jiebin
 * @data 2022/11/14
 **/
public class NetWorkTypeEnumHandler extends BaseTypeHandler<NetWorkTypeEnum> {
    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, NetWorkTypeEnum parameter, JdbcType jdbcType)
            throws SQLException {
        ps.setInt(i, parameter.getValue());
    }


    @Override
    public NetWorkTypeEnum getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return NetWorkTypeEnum.parse(rs.getInt(columnName));
    }


    @Override
    public NetWorkTypeEnum getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return NetWorkTypeEnum.parse(rs.getInt(columnIndex));
    }


    @Override
    public NetWorkTypeEnum getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return NetWorkTypeEnum.parse(cs.getInt(columnIndex));
    }
}
